package com.it.od.old202211;

import java.util.Scanner;
import java.util.*;

/**
 * 叠积木 [200]
 */
public class Main2 {
    public static void main(String[] args) {
        //处理输入
        Scanner in = new Scanner(System.in);
        String[] s = in.nextLine().split(" ");
        int[] nums = new int[s.length];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = Integer.parseInt(s[i]);
        }

        //求和并排序
        int sum = 0;
        for (int num : nums) {
            sum += num;
        }
        Arrays.sort(nums);

        // 墙的最大层数
        int max_layer = -1;
         // i表示可能堆的层数
        for (int i = 2; i <= sum / 2; i++) {
            // 如果所有数字的和除不尽层数，自然肯定不满足条件
            if (sum % i != 0) continue;
            // 每一层的长度为layer_length
            int layer_length = sum / i;
            if(nums[nums.length - 1] > layer_length){
                continue;
            }
            int[] arr = new int[i];
            Arrays.fill(arr, layer_length);
            // 递归找层数
            if (dfs (nums, nums.length - 1, 0, arr, i, layer_length)) {
                max_layer = Math.max(max_layer, i);
            }
        }
        System.out.println(max_layer);
    }
    public static boolean dfs(int[] nums, int cur, int used_cnt, int[] arr, int k, int layer_length){
        if(cur < 0){
            return true;
        }
        if (used_cnt < k) {
            arr[used_cnt] = nums[cur];
            if (dfs(nums, cur - 1, used_cnt + 1, arr, k, layer_length)) {
                return true;
            }
            arr[used_cnt] = 0;
        }

        for(int i = 0; i < used_cnt; i++){

            if (i > 0 && arr[i] == arr[i - 1]) continue;
            if (arr[i] + nums[cur] <= layer_length) {
                arr[i] += nums[cur];
                if (dfs(nums, cur - 1, used_cnt, arr, k, layer_length)) return true;
                arr[i] -= nums[cur];
            }
        }
        return false;
    }
}
